package com.gel.codegeneration.utils;

import com.gel.codegeneration.common.enums.ErrorCode;
import com.gel.codegeneration.convention.exception.BusinessException;

public class ThrowUtils
{

    /*条件成立抛出异常*/
    public static void throwIf(boolean condition, RuntimeException runtimeException)
    {
        if (condition)
        {
            throw runtimeException;
        }
    }

    public static void throwIf(boolean condition, ErrorCode errorCode, String message)
    {
        if (condition)
        {
            throwIf(condition,  new BusinessException(errorCode, message));
        }
    }

    public static void throwIf(boolean condition, ErrorCode errorCode)
    {
        throwIf(condition,new BusinessException(errorCode));
    }
}
